import { http } from '@/utils/http'
import { listInfo } from '../common/model'
import { queryInfo } from '../edu/lesson/model'

export enum Api {
	aggregateUrl = '/edu/teachers/stat/aggregate', // 学习报告
	uploadUrl = '/resource/oss/upload', // 上传文件
	learnRecordUrl = '/edu/app/students/study/list',
	LogoutUrl = '/auth/logout',
	SSECloseUrl = '/resource/sse/close',
	noticeListUrl = '/edu/edunotice/userNoticeList',
	noticeDetailsUrl = '/edu/edunotice/',
	noticeConfigUrl = '/edu/app/setting', // 新增App配置
	noticeConfigDetailUrl = '/edu/app/setting/detail', // 获取配置详情
	findInviteMsgUrl = '/edu/message/group/findInviteMsg', // 获取邀请消息
	discussionLikeUrl = '/edu/discussionLike/list', // 查询点赞列表
	examListUrl = '/edu/examPlan/list', // 我的考试
	examDetailsUrl = '/edu/examPlan/', // 我的考试详情
	examRecordsUrl = '/edu/app/teacher/exam/learning', // 查询考试记录列表  学情分析
	teacherDetailsUrl = '/edu/app/teacher/', // 教师端app 教师个人信息
	deleteStudentsUrl = '/edu/students/', // 删除学生
	noticeIsReadUrl = '/edu/noticeUser/isRead', // 公告已读
	classListUrl = '/edu/app/teacher/class/list', // 班级管理
	statForExamUrl = '/edu/app/teacher/exam/statForExam', // 考试统计
	publishExamPlanurl = '/edu/examPlan', // 发布课程
	findNoticeUrl = '/edu/app/discussion/findNotice', // 查询点赞列表
}
export const updateAvatarUrl = '/system/user/profile/avatar'

/** 学习报告 */
export const aggregateApi = () => {
	return http.get<any>(Api.aggregateUrl)
}

/** 上传文件 */
export const uploadFileApi = (params : any) => {
	return http.post<any>(Api.uploadUrl, { params })
}

/** 修改用户头像 */
export const updateAvatarApi = (params : any) => {
	return http.post<any>(updateAvatarUrl, { params })
}

/** 历史学习记录 */
export const learnRecordApi = (params : { pageNum : number; pageSize : number; content ?: string }) => {
	return http.get<listInfo>(Api.learnRecordUrl, params)
}

/** 查询接收公告 */
export const noticeListApi = (params : { pageNum : number; pageSize : number; content ?: string }) => {
	return http.get<listInfo>(Api.noticeListUrl, params)
}

/** 查询公告详情 */
export const noticeDetailsApi = (id : string) => {
	return http.get<queryInfo>(Api.noticeDetailsUrl + id)
}

/** 获取邀请消息 */
export const findInviteMsgApi = (params : {
	pageNum : number
	pageSize : number
	content ?: string
}) => {
	return http.get<listInfo>(Api.findInviteMsgUrl, params)
}

/** 查询点赞列表 */
export const discussionLikeApi = (params : {
	pageNum : number
	pageSize : number
	content ?: string
}) => {
	return http.get<listInfo>(Api.discussionLikeUrl, params)
}

/** 查询评论点赞列表 */
export const findNoticeApi = (params: {
  pageNum: number
  pageSize: number
  content?: string
}) => {
  return http.get<queryInfo>(Api.findNoticeUrl, params)
}

/** 查询考试列表 */
export const examListApi = (params : { pageNum : number; pageSize : number; content ?: string }) => {
	return http.get<listInfo>(Api.examListUrl, params)
}

/** 查询考试详情 */
export const examDetailsApi = (id : string) => {
	return http.get<queryInfo>(Api.examDetailsUrl + id)
}

/** 查询学生列表 */
export const examRecordsApi = (params : { examPlanId : string }) => {
	return http.get<listInfo>(Api.examRecordsUrl, params)
}

/** 考试统计 */
export const statForExamApi = (params : { examPlanId : string }) => {
	return http.get<queryInfo>(Api.statForExamUrl, params)
}

/** 查询班级学生列表 */
export const classListApi = () => {
	return http.get<queryInfo>(Api.classListUrl)
}

/** 教师个人信息 */
export const teacherDetailsApi = (teacherId : string) => {
	return http.get<queryInfo>(Api.teacherDetailsUrl + teacherId)
}

/**
 * 删除学生
 * @param id
 */
export function deleteStudentsApi(studentIds : string) {
	return http.delete<void>(Api.deleteStudentsUrl + studentIds)
}

/**
 * 公告已读
 */
export function noticeIsReadApi(params : { id : string }) {
	return http.post<queryInfo>(Api.noticeIsReadUrl, params)
}

/**
 * 发布考试
 */
export function publishExamPlanApi(params : any) {
	return http.put<queryInfo>(Api.publishExamPlanurl, params)
}

/**
 * 发布考试
 */
// export function publishExamPlanApi(params : any) {
// 	return http.put<queryInfo>(Api.publishExamPlanurl, params)
// }

/**
 * 用户登出
 * @returns
 */
export function doLogoutApi() {
	return http.post<void>(Api.LogoutUrl)
}

/**
 * 登出时关闭sse
 * @returns sse关闭
 */
export function sseCloseApi() {
	return http.get<void>(Api.SSECloseUrl)
}

/** 新增App通知配置 */
export const noticeConfigApi = (
	receiveMessage : number,
	receiveNotice : number,
	receiveGroup : number,
	receiveIm : number,
) => {
	return http.post<any>(Api.noticeConfigUrl, {
		receiveMessage,
		receiveNotice,
		receiveIm,
		receiveGroup,
	})
}

/** 新增App通知配置 */
export const noticeConfigDetailApi = () => {
	return http.get<any>(Api.noticeConfigDetailUrl)
}